<?php

namespace app\common\shop;

use think\Db;
use think\Model;
use traits\model\SoftDelete;

// 代理商
class UserAgentLevelModel extends model {
    // 完整数据表名
    protected $table = 'user_agent_level';
    /**
     * [建表]
     * @return
     */
    public static function createTable(){
        return Db::query("CREATE TABLE If Not Exists `user_agent_level` (
              `id` int(11) NOT NULL AUTO_INCREMENT,
              `name` varchar(255) NOT NULL  DEFAULT '0' COMMENT '名称',
              `direct` int(11) NOT NULL  DEFAULT '0' COMMENT '直推人数',
              `team` int(11) NOT NULL DEFAULT '0' COMMENT '团队总人数',
              `selfperformance` decimal(22,2) NOT NULL DEFAULT '0' COMMENT '个人业绩',
              `teamperformance` decimal(22,2) NOT NULL DEFAULT '0' COMMENT '团队业绩',
              `teamlevelid` int(11) NOT NULL DEFAULT '0' COMMENT '需要团长等级',
              `teamnumber` int(11) NOT NULL DEFAULT '0' COMMENT '需要团长等级人数',
              `percentage` decimal(22,2) NOT NULL DEFAULT '0' COMMENT '佣金提成',
              `peers` decimal(22,2) DEFAULT NULL DEFAULT '0' COMMENT '平级奖',
              `createtime` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '时间',
              PRIMARY KEY (`id`)
            ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='代理商设置表'");
    }
    /**
     * [添加]
     * @return
     */
    public function add($data){
        $data['createtime'] = time();
        return self::insertGetId($data);
    }
}